<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>const 定义常量</title>
</head>
<body>
  <script>
    // 声明常量
    const SCHOOL = '尚硅谷';

    // 1.  一定要赋初始值
    // const A;    // 报错： Uncaught SyntaxError: Missing initializer in const declaration

    // 2. 一般常量使用大写（潜规则）
    // const a = 100;

    // 3. 常量的值不能修改
    // const SCHOOL = "ATGUIGU";   // 报错： Uncaught SyntaxError: Identifier 'SCHOOL' has already been declared

    // 4.块级作用域
    /* 
      {
        const PLAYER = 'UZI'
      }

      console.log(PLAYER) 

      Uncaught ReferenceError: PLAYER is not defined
    */

    // 5. 对于数组和对象的元素修改，不算做对常量的修改，不会报错
    const TEAM = ['UZI', 'MXLG', 'Ming', 'Letme'];  
    TEAM.push('Meiko'); // 对应的栈不改变（内存地址不变） 只是堆的内容改变

    // TEAM = 100;         // 对应的栈改变   直接报错  Uncaught TypeError: Assignment to constant variable.

    
  </script>   
</body>
</html>